/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.p10.miage.gestionabsence.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author huynal
 */
public class PresenceActionForm extends org.apache.struts.action.ActionForm {
    
    private int idEtudiant;
    private int idAgenda;


    /**
     * @return
     */
    public int getidEtudiant() {
        return idEtudiant;
    }

    /**
     * @param i
     */
    public void setidEtudiant(int newIdEtudiant) {
        idEtudiant = newIdEtudiant;
    }
    
    /**
     * @return
     */
    public int getidAgenda() {
        return idAgenda;
    }

    /**
     * @param i
     */
    public void setNumber(int newIdAgenda) {
        idAgenda = newIdAgenda;
    }

    /**
     *
     */
    public PresenceActionForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        
        if (this.idEtudiant == 0 || this.idEtudiant < 8) {
            errors.add("id etudiant", new ActionMessage("errors.required", " id etudiant"));
        }
        else if (this.idAgenda == 0 || this.idAgenda < 8) {
            errors.add("id agenda", new ActionMessage("errors.required", " id agenda"));
        }    
        return errors;
    }
}
